package com.numberone.web.controller.abouthonor;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.numberone.common.annotation.Log;
import com.numberone.common.enums.BusinessType;
import com.numberone.system.domain.AboutHonor;
import com.numberone.system.service.IAboutHonorService;
import com.numberone.framework.web.base.BaseController;
import com.numberone.common.page.TableDataInfo;
import com.numberone.common.base.AjaxResult;
import com.numberone.common.utils.poi.ExcelUtil;

/**
 * 企业荣誉 信息操作处理
 * 
 * @author 于沛麟
 * @date 2020-09-27
 */
@Controller
@RequestMapping("/system/aboutHonor")
public class AboutHonorController extends BaseController
{
    private String prefix = "system/aboutHonor";
	
	@Autowired
	private IAboutHonorService aboutHonorService;
	
	@RequiresPermissions("system:aboutHonor:view")
	@GetMapping()
	public String aboutHonor()
	{
	    return prefix + "/aboutHonor";
	}
	
	/**
	 * 查询企业荣誉列表
	 */
	@RequiresPermissions("system:aboutHonor:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AboutHonor aboutHonor)
	{
		startPage();
        List<AboutHonor> list = aboutHonorService.selectAboutHonorList(aboutHonor);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出企业荣誉列表
	 */
	@RequiresPermissions("system:aboutHonor:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AboutHonor aboutHonor)
    {
    	List<AboutHonor> list = aboutHonorService.selectAboutHonorList(aboutHonor);
        ExcelUtil<AboutHonor> util = new ExcelUtil<AboutHonor>(AboutHonor.class);
        return util.exportExcel(list, "aboutHonor");
    }
	
	/**
	 * 新增企业荣誉
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存企业荣誉
	 */
	@RequiresPermissions("system:aboutHonor:add")
	@Log(title = "企业荣誉", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AboutHonor aboutHonor)
	{		
		return toAjax(aboutHonorService.insertAboutHonor(aboutHonor));
	}

	/**
	 * 修改企业荣誉
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		AboutHonor aboutHonor = aboutHonorService.selectAboutHonorById(id);
		mmap.put("aboutHonor", aboutHonor);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存企业荣誉
	 */
	@RequiresPermissions("system:aboutHonor:edit")
	@Log(title = "企业荣誉", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AboutHonor aboutHonor)
	{		
		return toAjax(aboutHonorService.updateAboutHonor(aboutHonor));
	}
	
	/**
	 * 删除企业荣誉
	 */
	@RequiresPermissions("system:aboutHonor:remove")
	@Log(title = "企业荣誉", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(aboutHonorService.deleteAboutHonorByIds(ids));
	}
	
}
